//preload
var trash_e = new Image();
trash_e.src = "pngs/trashe.png";
var trash_f = new Image();
trash_f.src = "pngs/trashf.png";
var color_box = new Image();
color_box.src = "pngs/palette.png";
var color_pens = new Image();
color_pens.src = "pngs/colors.png";
//
var note_live = new Array();
note_live[0] = 0;
note_live[1] = 0;
note_live[2] = 0;
note_live[3] = 0;
note_live[4] = 0;
note_live[5] = 0;
note_live[6] = 0;
//
var note_state = new Array();
//
note_state[0] = "d";
note_state[1] = "d";
note_state[2] = "d";
note_state[3] = "d";
note_state[4] = "d";
note_state[5] = "d";
note_state[6] = "d";
//
var text_notes = new Array();
//
text_notes[0] = "I am a Note";
text_notes[1] = "I can be Moved";
text_notes[2] = "Make a Memo";
text_notes[3] = "A Reminder";
text_notes[4] = "Tasks to Complete";
text_notes[5] = "Note a Point";
text_notes[6] = "Jot a Thought";
//
var back_color = new Array();
//
back_color[0] = "a";
back_color[1] = "b";
back_color[2] = "c";
back_color[3] = "d";
back_color[4] = "e";
back_color[5] = "f";
back_color[6] = "g";
//
var store_notes = new Array();
//
var fore_color = new Array();
//
fore_color[0] = "a";
fore_color[1] = "b";
fore_color[2] = "c";
fore_color[3] = "d";
fore_color[4] = "e";
fore_color[5] = "f";
fore_color[6] = "g";
//
var ztop_max = 21;
var ztop_nom = 20;
var ztop_cur = 21;
//
function read_notes(){
show_mem();
notes_show();
}
//
//drag-drop
var a_grip = document.getElementById("a_hand");
var a_note   = document.getElementById("note_a");
Drag.init(a_grip, a_note, 5, 5, 50, 382 );
a_note.onDragStart = function(x, y){bring_top(note_a);}
//
var b_grip = document.getElementById("b_hand");
var b_note   = document.getElementById("note_b");
Drag.init(b_grip, b_note, 5, 5, 50, 382 );
b_note.onDragStart = function(x, y){bring_top(note_b);}
//
var c_grip = document.getElementById("c_hand");
var c_note   = document.getElementById("note_c");
Drag.init(c_grip, c_note, 5, 5, 50, 382 );
c_note.onDragStart = function(x, y){bring_top(note_c);}
//
var d_grip = document.getElementById("d_hand");
var d_note   = document.getElementById("note_d");
Drag.init(d_grip, d_note, 5, 5, 50, 382 );
d_note.onDragStart = function(x, y){bring_top(note_d);}
//
var e_grip = document.getElementById("e_hand");
var e_note   = document.getElementById("note_e");
Drag.init(e_grip, e_note, 5, 5, 50, 382 );
e_note.onDragStart = function(x, y){bring_top(note_e);}
//
var f_grip = document.getElementById("f_hand");
var f_note   = document.getElementById("note_f");
Drag.init(f_grip, f_note, 5, 5, 50, 382 );
f_note.onDragStart = function(x, y){bring_top(note_f);}
//
var g_grip = document.getElementById("g_hand");
var g_note   = document.getElementById("note_g");
Drag.init(g_grip, g_note, 5, 5, 50, 382 );
g_note.onDragStart = function(x, y){bring_top(note_g);}
//
var db_grip = document.getElementById("db_hand");
var db_note   = document.getElementById("db_df");
Drag.init(db_grip, db_note, 5, 5, 50, 82 );
db_note.onDragStart = function(x, y){bring_top(db_df);}
//
function HideContent(dragy,num_not) {
document.getElementById(dragy).style.visibility = "hidden";
note_state[eval(num_not)] = "h";
document.images.trash_can.src = trash_f.src;
}
//
function ShowContent() {
if(note_state[0]=="h"){note_a.style.visibility = "visible";note_state[0] = "v";}
if(note_state[1]=="h"){note_b.style.visibility = "visible";note_state[1] = "v";}
if(note_state[2]=="h"){note_c.style.visibility = "visible";note_state[2] = "v";}
if(note_state[3]=="h"){note_d.style.visibility = "visible";note_state[3] = "v";}
if(note_state[4]=="h"){note_e.style.visibility = "visible";note_state[4] = "v";}
if(note_state[5]=="h"){note_f.style.visibility = "visible";note_state[5] = "v";}
if(note_state[6]=="h"){note_g.style.visibility = "visible";note_state[6] = "v";}
document.images.trash_can.src = trash_e.src;
}
//
var new_done =0;
//
function new_note() {
if(note_state[0]=="d" && new_done ==0){note_a.style.visibility = "visible";note_state[0] = "v";new_done =1;bring_top(note_a);}
if(note_state[1]=="d" && new_done ==0){note_b.style.visibility = "visible";note_state[1] = "v";new_done =1;bring_top(note_b);}
if(note_state[2]=="d" && new_done ==0){note_c.style.visibility = "visible";note_state[2] = "v";new_done =1;bring_top(note_c);}
if(note_state[3]=="d" && new_done ==0){note_d.style.visibility = "visible";note_state[3] = "v";new_done =1;bring_top(note_d);}
if(note_state[4]=="d" && new_done ==0){note_e.style.visibility = "visible";note_state[4] = "v";new_done =1;bring_top(note_e);}
if(note_state[5]=="d" && new_done ==0){note_f.style.visibility = "visible";note_state[5] = "v";new_done =1;bring_top(note_f);}
if(note_state[6]=="d" && new_done ==0){note_g.style.visibility = "visible";note_state[6] = "v";new_done =1;bring_top(note_g);}
new_done =0;
}
//
//set paper color
var active_note;
var active_num;
//
function paper_set(paper_note,note_num) {
bring_top(eval(paper_note));
notes_show();
switch (paper_note){
case 'note_a':
show_text(4, 'a_txt');
break;
case 'note_b':
show_text(4, 'b_txt');
break;
case 'note_c':
show_text(4, 'c_txt');
break;
case 'note_d':
show_text(4, 'd_txt');
break;
case 'note_e':
show_text(4, 'e_txt');
break;
case 'note_f':
show_text(4, 'f_txt');
break;
case 'note_g':
show_text(4, 'g_txt');
break;
}
active_note = document.getElementById(paper_note);
active_num =  eval(note_num);
}
//
var bc_a = "#FFFFD2";
var bc_b = "#EFEFEF";
var bc_c = "#FFE8F3";
var bc_d = "#F1EDE4";
var bc_e = "#E2F1F1";
var bc_f = "#D9ECFF";
var bc_g = "#FFE1D2";
var bc_h = "#E1FFE1";
var bc_i = "#D4FFFF";
var bc_j = "#E1E1FF";
var bc_k = "#FFFFFF";
var bc_l = "#E4E4F1";
//
function set_bcol(the_bcol){
active_note.style.background = eval(the_bcol);
back_color[active_num] = the_bcol.charAt(3);
notes_show();
}
// set pen color
var fc_a = "#959500";
var fc_b = "#808080";
var fc_c = "#E10000";
var fc_d = "#0078B3";
var fc_e = "#3E7B7B";
var fc_f = "#0000D2";
var fc_g = "#666666";
var fc_h = "#00A600";
var fc_i = "#804040";
var fc_j = "#9D009D";
var fc_k = "#000000";
var fc_l = "#6A6AB5";
//
function pen_set(pen_note,note_dex) {
bring_top(eval(pen_note));
notes_show();
switch (pen_note){
case 'note_a':
show_text(5, 'a_txt');
break;
case 'note_b':
show_text(5, 'b_txt');
break;
case 'note_c':
show_text(5, 'c_txt');
break;
case 'note_d':
show_text(5, 'd_txt');
break;
case 'note_e':
show_text(5, 'e_txt');
break;
case 'note_f':
show_text(5, 'f_txt');
break;
case 'note_g':
show_text(5, 'g_txt');
break;
}
active_note = document.getElementById(pen_note);
active_num =  eval(note_dex);
}
//
function set_fcol(the_fcol){
active_note.style.color = eval(the_fcol);
fore_color[active_num] = the_fcol.charAt(3);
notes_show();
}
//
//
function notes_show(){
linktext[1]=text_notes[0];
show_text(1, 'a_txt');
linktext[1]=text_notes[1];
show_text(1, 'b_txt');
linktext[1]=text_notes[2];
show_text(1, 'c_txt');
linktext[1]=text_notes[3];
show_text(1, 'd_txt');
linktext[1]=text_notes[4];
show_text(1, 'e_txt');
linktext[1]=text_notes[5];
show_text(1, 'f_txt');
linktext[1]=text_notes[6];
show_text(1, 'g_txt');
//
note_a.style.background = eval("bc_" + back_color[0]);
note_b.style.background = eval("bc_" + back_color[1]);
note_c.style.background = eval("bc_" + back_color[2]);
note_d.style.background = eval("bc_" + back_color[3]);
note_e.style.background = eval("bc_" + back_color[4]);
note_f.style.background = eval("bc_" + back_color[5]);
note_g.style.background = eval("bc_" + back_color[6]);
//
a_txt.style.color = eval("fc_" + fore_color[0]);
b_txt.style.color = eval("fc_" + fore_color[1]);
c_txt.style.color = eval("fc_" + fore_color[2]);
d_txt.style.color = eval("fc_" + fore_color[3]);
e_txt.style.color = eval("fc_" + fore_color[4]);
f_txt.style.color = eval("fc_" + fore_color[5]);
g_txt.style.color = eval("fc_" + fore_color[6]);
//
if(note_state[0]=="v"){note_a.style.visibility = "visible";}
if(note_state[1]=="v"){note_b.style.visibility = "visible";}
if(note_state[2]=="v"){note_c.style.visibility = "visible";}
if(note_state[3]=="v"){note_d.style.visibility = "visible";}
if(note_state[4]=="v"){note_e.style.visibility = "visible";}
if(note_state[5]=="v"){note_f.style.visibility = "visible";}
if(note_state[6]=="v"){note_g.style.visibility = "visible";}
}
//
//
function reset_ztop() {
note_a.style.zIndex = ztop_nom;
note_b.style.zIndex = ztop_nom;
note_c.style.zIndex = ztop_nom;
note_d.style.zIndex = ztop_nom;
note_e.style.zIndex = ztop_nom;
note_f.style.zIndex = ztop_nom;
note_g.style.zIndex = ztop_nom;
}
//
function bring_top(top_note) {
top_note.style.zIndex = ztop_cur;
  if(ztop_cur <99){ztop_cur++;}
  else {
    reset_ztop();
    top_note.style.zIndex = ztop_max;
    ztop_cur = ztop_max + 1;
    }
}
//
//
function save_note(save_msg){
if(note_live[eval(save_msg)] == 1){
text_notes[eval(save_msg)] = eval("document.take_note_" + eval(save_msg) + ".take_msg_" + eval(save_msg) + ".value") ;
note_live[eval(save_msg)] = 0;
}
save_mem();
}
//
function edit_note(edit_msg,msg_no) {
linktext[6]="<form name='take_note_" + eval(msg_no) + "' action=''><textarea name='take_msg_" + eval(msg_no) + "' onkeypress='return imposeMaxLength(this,100);' wrap='physical' rows='5' cols='25'>"+ text_notes[eval(msg_no)] + "</textarea></form>"
show_text(6, edit_msg);
note_live[eval(msg_no)] = 1;
}
//
//Idea from http://psacake.com/web/js.asp
var text_entry;
//
function imposeMaxLength(Object, MaxLen)
{
if (Object.value.length >= MaxLen){
  text_entry = Object.value;
  Object.value = text_entry.substr(0,100);
}
}
//
//check cookies enabled
function show_mem() {
createCookie('xyztest8abc', 'san',1);
if (readCookie('xyztest8abc') == 'san'){
text_notes[0] = text_notes[0] + "!";
read_mem();
}
else {
note_a.style.visibility = "visible";
text_notes[0] = "On Cookies !";
}
}
//end check
//
function read_mem() {
if (readCookie('pinnote1delabs60note0')){
store_notes[0] = readCookie('pinnote1delabs60note0');
store_notes[1] = readCookie('pinnote1delabs60note1');
store_notes[2] = readCookie('pinnote1delabs60note2');
store_notes[3] = readCookie('pinnote1delabs60note3');
store_notes[4] = readCookie('pinnote1delabs60note4');
store_notes[5] = readCookie('pinnote1delabs60note5');
store_notes[6] = readCookie('pinnote1delabs60note6');
//
text_notes[0]= store_notes[0].substring(3);
text_notes[1]= store_notes[1].substring(3);
text_notes[2]= store_notes[2].substring(3);
text_notes[3]= store_notes[3].substring(3);
text_notes[4]= store_notes[4].substring(3);
text_notes[5]= store_notes[5].substring(3);
text_notes[6]= store_notes[6].substring(3);
//
back_color[0] = store_notes[0].charAt(0);
back_color[1] = store_notes[1].charAt(0);
back_color[2] = store_notes[2].charAt(0);
back_color[3] = store_notes[3].charAt(0);
back_color[4] = store_notes[4].charAt(0);
back_color[5] = store_notes[5].charAt(0);
back_color[6] = store_notes[6].charAt(0);
//
fore_color[0] = store_notes[0].charAt(1);
fore_color[1] = store_notes[1].charAt(1);
fore_color[2] = store_notes[2].charAt(1);
fore_color[3] = store_notes[3].charAt(1);
fore_color[4] = store_notes[4].charAt(1);
fore_color[5] = store_notes[5].charAt(1);
fore_color[6] = store_notes[6].charAt(1);
//
if(store_notes[0].charAt(2)=="v"){note_state[0] = "v";} else text_notes[0] = "New Note";
if(store_notes[1].charAt(2)=="v"){note_state[1] = "v";} else text_notes[1] = "New Note";
if(store_notes[2].charAt(2)=="v"){note_state[2] = "v";} else text_notes[2] = "New Note";
if(store_notes[3].charAt(2)=="v"){note_state[3] = "v";} else text_notes[3] = "New Note";
if(store_notes[4].charAt(2)=="v"){note_state[4] = "v";} else text_notes[4] = "New Note";
if(store_notes[5].charAt(2)=="v"){note_state[5] = "v";} else text_notes[5] = "New Note";
if(store_notes[6].charAt(2)=="v"){note_state[6] = "v";} else text_notes[6] = "New Note";
}
}
//
function save_mem() {
if(note_live[0] == 1){text_notes[0] = document.take_note_0.take_msg_0.value;note_live[0] = 0;}
if(note_live[1] == 1){text_notes[1] = document.take_note_1.take_msg_1.value;note_live[1] = 0;}
if(note_live[2] == 1){text_notes[2] = document.take_note_2.take_msg_2.value;note_live[2] = 0;}
if(note_live[3] == 1){text_notes[3] = document.take_note_3.take_msg_3.value;note_live[3] = 0;}
if(note_live[4] == 1){text_notes[4] = document.take_note_4.take_msg_4.value;note_live[4] = 0;}
if(note_live[5] == 1){text_notes[5] = document.take_note_5.take_msg_5.value;note_live[5] = 0;}
if(note_live[6] == 1){text_notes[6] = document.take_note_6.take_msg_6.value;note_live[6] = 0;}
//
store_notes[0] = back_color[0] + fore_color[0] + note_state[0] + text_notes[0];
store_notes[1] = back_color[1] + fore_color[1] + note_state[1] + text_notes[1];
store_notes[2] = back_color[2] + fore_color[2] + note_state[2] + text_notes[2];
store_notes[3] = back_color[3] + fore_color[3] + note_state[3] + text_notes[3];
store_notes[4] = back_color[4] + fore_color[4] + note_state[4] + text_notes[4];
store_notes[5] = back_color[5] + fore_color[5] + note_state[5] + text_notes[5];
store_notes[6] = back_color[6] + fore_color[6] + note_state[6] + text_notes[6];
//
createCookie('pinnote1delabs60note0',store_notes[0],999);
createCookie('pinnote1delabs60note1',store_notes[1],999);
createCookie('pinnote1delabs60note2',store_notes[2],999);
createCookie('pinnote1delabs60note3',store_notes[3],999);
createCookie('pinnote1delabs60note4',store_notes[4],999);
createCookie('pinnote1delabs60note5',store_notes[5],999);
createCookie('pinnote1delabs60note6',store_notes[6],999);
notes_show();
}
//
//data liberation
var db_dump;
var note_blck = new Array();
var base_notes = new Array();
//
function backup_db(){
db_dump ="";
for (i = 0; i < 7; i++){
db_dump = db_dump + text_notes[i] + "|" + back_color[i] + "|" + fore_color[i] + "|" + note_state[i] + "||";
}
db_df.style.visibility = "visible";
linktext[6]= "Copy and Store Text Database<br/><br/>" + "<form name='take_note_7' action=''><textarea id='dbarea' name='take_msg_7' readonly='readonly' wrap='physical' rows='24' cols='22' onClick='sel_all();'>" + db_dump + "</textarea></form>"
show_text(6, 'db_txt');
}
//
function restore_db(){
db_df.style.visibility = "visible";
linktext[6]= "Paste Text and Click <font onclick='dp_put();'><b>Restore</b></font><br/><br/>" + "<form name='take_note_7' action=''><textarea id='dbarea' name='take_msg_7' wrap='physical' rows='24' cols='22'></textarea></form>"
show_text(6, 'db_txt');
}
//
function dp_put(){
db_dump ="";
db_dump = document.take_note_7.take_msg_7.value
if(db_dump==""){
linktext[6]= "No data was Provided ! Use this only if you know what you are doing."
show_text(6, 'db_txt');
}
else
{
try
  {
base_notes = db_dump.split("||");
for (i = 0; i < 7; i++){
note_blck = base_notes[i].split("|");
text_notes[i] = note_blck[0]
back_color[i] = note_blck[1]
fore_color[i] = note_blck[2]
note_state[i] = note_blck[3]
}
linktext[6]= "Done in a Jiffy ! But remember to always store, your Backed up text data, date wise in a CDROM or Flash Drive and Lock it in a Safe, its your data."
show_text(6, 'db_txt');
save_mem();
  }
catch(err)
  {
linktext[6]= "Something Wrong Somewhere, The Text Database is Pipe | Seperated. Refresh and See if Notes work, Else Use the Fix Reset Notes Control Icon."
show_text(6, 'db_txt');
  }
}
}
//
function fix_db(){
db_df.style.visibility = "visible";
linktext[6]= "Would you Like to Set all the Notes and This Jot Notes Gadget to Factory Default Settings.<br/><br/>You will lose the notes and customization, Use it only when Jot Notes does not Work anymore!<br/><br/> Proceed to Notes Reset ! Click Here <font onclick='reset_db();'><b>Reset Jot Notes</b></font><br/><br/>."
show_text(6, 'db_txt');
}

function reset_db(){
text_notes[0] = "I am a Note";
text_notes[1] = "I can be Moved";
text_notes[2] = "Make a Memo";
text_notes[3] = "A Reminder";
text_notes[4] = "Tasks to Complete";
text_notes[5] = "Note a Point";
text_notes[6] = "Jot a Thought";
//
back_color[0] = "a";
back_color[1] = "b";
back_color[2] = "c";
back_color[3] = "d";
back_color[4] = "e";
back_color[5] = "f";
back_color[6] = "g";
//
fore_color[0] = "a";
fore_color[1] = "b";
fore_color[2] = "c";
fore_color[3] = "d";
fore_color[4] = "e";
fore_color[5] = "f";
fore_color[6] = "g";
//
note_state[0] = "d";
note_state[1] = "d";
note_state[2] = "d";
note_state[3] = "d";
note_state[4] = "d";
note_state[5] = "d";
note_state[6] = "d";
//
save_mem();
linktext[6]= "You asked for it! Now this Notebook is New, just like when you found it first."
show_text(6, 'db_txt');
}
//
function sel_all()
{
document.take_note_7.take_msg_7.focus();
document.take_note_7.take_msg_7.select();
}
//
// Online Help Start
//adapted from Link Description script- www.dynamicdrive.com
var linktext=new Array()
linktext[0]=""
linktext[1]=""
linktext[2]=""
linktext[3]=""
linktext[4]="<img align='middle' usemap='#back_palette' width=180 height=65 src='pngs/palette.png' alt='Click a Color' title='Click a Color' border=0>"
linktext[5]="<img align='middle' usemap='#front_palette' width=180 height=65 src='pngs/colors.png' alt='Click a Color' title='Click a Color' border=0>"
linktext[6]=""
//
//linktext[5]="<form name='show_alm' action=''><input readonly='readonly' class='alm_show' name='read_msg' size='12' value='" + text_a  + "' type='text'><input align='top' onclick='rst_alm();' alt='Ok' title='Ok' type='image' src='pngs/done.png'></form>"
//
var ns6=document.getElementById&&!document.all
var ie=document.all

function show_text(thetext, whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}

function resetit(whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=' '
else if (ns6) document.getElementById(whichdiv).innerHTML=' '
}
//  Online Help End
//
window.onload=read_notes;
// end of the screenplay
